<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title></title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>

<script type="text/javascript">
	var ge;
	var placemark;
	var dragInfo = null;

	google.load("earth", "1");

	function init() {
		google.earth.createInstance('map3d', initCallback, failureCallback);
	}

	function initCallback(instance) {
		ge = instance;
		ge.getWindow().setVisibility(true);

		// Create the placemark and add it to Earth.
		placemark = ge.createPlacemark('');
		var point = ge.createPoint('');
		point.setLatitude(37);
		point.setLongitude(-122);
		placemark.setGeometry(point);
		placemark.setName('Drag Me!');
		ge.getFeatures().appendChild(placemark);

		// Look at the placemark we created.
		var la = ge.createLookAt('');
		la.set(37, -122, 0, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 5000);
		ge.getView().setAbstractView(la);

		// Listen for mousedown on the window (look specifically for point placemarks).
		google.earth
				.addEventListener(ge.getWindow(), 'mousedown',
						function(event) {
							if (event.getTarget().getType() == 'KmlPlacemark'
									&& event.getTarget().getGeometry()
											.getType() == 'KmlPoint') {
								var placemark = event.getTarget();
								dragInfo = {
									placemark : placemark,
									dragged : false
								};
							}
						});

		// Listen for mousemove on the globe.
		google.earth.addEventListener(ge.getGlobe(), 'mousemove', function(
				event) {
			if (dragInfo) {
				event.preventDefault();
				var point = dragInfo.placemark.getGeometry();
				point.setLatitude(event.getLatitude());
				point.setLongitude(event.getLongitude());
				dragInfo.dragged = true;
			}
		});

		// Listen for mouseup on the window.
		google.earth.addEventListener(ge.getWindow(), 'mouseup',
				function(event) {
					if (dragInfo) {
						if (dragInfo.dragged) {
							// If the placemark was dragged, prevent balloons from popping up.
							event.preventDefault();
						}

						dragInfo = null;
					}
				});

	}

	function failureCallback(errorCode) {
	}
	
	google.setOnLoadCallback(init);
</script>

</head>

<body>
	<div id="map3d" style="height: 600px; width: 1000px;"></div>
</body>
</html>
